package com.itheima.test;

import java.io.File;

public class Delete {
    public static void main(String[] args) {
        File file = new File("D:\\Windows");
        deleteDir(file);
    }

    private static void deleteDir(File dir) {
        if(!dir.exists()){
            return;
        }
        File[] files = dir.listFiles();
        for (File file : files) {
            if(file.isFile()){
                file.delete();
            }   else{
                deleteDir(file);
            }
        }
        dir.delete();
    }


}
